﻿//-------------------------------------------------------------------------------------------
// <copyright file="Transaction.cs" company="Russell Wilkins">
//     Copyright (c) Russell Wilkins 2014. All Rights Reserved.
// </copyright>
// <author>Russell Wilkins</author>
// <license href="license.txt">
//     The use of this software is governed by the Microsoft Public License
//     which is included with this distribution.
// </license>
//-------------------------------------------------------------------------------------------
namespace Ripple.Data
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    /// <summary>
    /// Base class for transactions
    /// </summary>
    public abstract class Transaction : Entity
    {
        private Account account;

        private bool AccountLoaded;

        protected Transaction(IRippleContext rippleContext, TransactionType transactionType)
            : base(rippleContext)
        {
            this.TransactionType = transactionType;
        }

        public Account Account
        {
            get
            {
                if (!this.AccountLoaded)
                {
                    this.account = this.RippleContext.Accounts.Get(this.AccountId);
                    this.AccountLoaded = true;
                }
                return this.account;
            }
        }

        public string AccountId { get; internal set; }

        public DateTime Date { get; internal set; }

        public int Fee { get; internal set; }

        public string Id { get; internal set; }

        public TransactionType TransactionType { get; internal set; }
    }
}